package com.xuyiwei.mayi.test;

/**
 * Created by xuyiwei on 2019/4/13.
 */
class ThreadLocalThreadRunnable implements Runnable{
    ThreadLocal<Integer> local = new ThreadLocal<Integer>(){
        @Override
        protected Integer initialValue() {
            return 0;
        }
    };
    @Override
    public void run() {
        System.out.println(local.get()+1);
    }
}
public class ThreadLocalThread {
    public static void main(String[] args) {
        ThreadLocalThreadRunnable runs = new ThreadLocalThreadRunnable();
        for(int i=1;i<100;i++){
            Thread t = new Thread(runs);
            t.start();
        }
    }
}
